package com.liming.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;

/**
 * @author liming
 * @date 2025/2/28
 */
@Getter
@AllArgsConstructor
public enum OrderStatusEnum {

    UNPAID(0, "未支付"),
    PAID(1, "已支付"),
    WAITING_FOR_DELIVERY(2, "待发货"),
    DELIVERED(3, "已发货"),
    WAITING_FOR_PICKUP(4, "待自提"),
    COMPLETED(5, "已完成"),
    UN_REFUNDED(6, "待退款"),
    CANCELED(7, "已取消"),
    // 并不存储在数据库中，只返回前端时有展示
    UN_EVALUATED(8, "待评价"),
    REFUNDED(9, "已退款");

    private final Integer code;
    private final String desc;


    /**
     * 可以点击完成的订单状态
     *
     * @return List<Integer> 订单状态码
     */
    public static List<Integer> canComplete() {
        return List.of(DELIVERED.getCode(), WAITING_FOR_PICKUP.getCode());
    }

    /**
     * 待处理的订单状态
     *
     * @return List<Integer> 订单状态码
     */
    public static List<Integer> undeliveredOrder() {
        return List.of(PAID.getCode(), WAITING_FOR_DELIVERY.getCode(), WAITING_FOR_PICKUP.getCode());
    }

    /**
     * 可以点击发货|自提的订单状态
     *
     * @return List<Integer> 订单状态码
     */
    public static List<Integer> canDeliverOrPickup() {
        return List.of(PAID.getCode(), WAITING_FOR_DELIVERY.getCode());
    }

    /**
     * 用户消费订单状态
     */
    public static List<Integer> consumeOrder() {
        return List.of(PAID.getCode(), WAITING_FOR_DELIVERY.getCode(), DELIVERED.getCode(), WAITING_FOR_PICKUP.getCode(), COMPLETED.getCode());
    }

    /**
     * 可以退款的订单状态
     */
    public static List<Integer> canRefund() {
        return List.of(PAID.getCode(), WAITING_FOR_DELIVERY.getCode(), WAITING_FOR_PICKUP.getCode());
    }

}
